bpf: Add kconfig knob for disabling unpriv bpf by default
authorDaniel Borkmann <daniel@iogearbox.net>
Tue, 11 May 2021 20:35:17 +0000 (22:35 +0200)
committerSalvatore Bonaccorso <carnil@debian.org>
Thu, 30 Sep 2021 19:36:41 +0000 (20:36 +0100)
commit5d37fba407014521359920cac3deb809f3f5f3ad
tree0d16daac2771b026a97a0af35f1a37da167ec9dc
parent57a5c024f7ea9b4f039687b8262aff53649a761f
bpf: Add kconfig knob for disabling unpriv bpf by default

Origin: https://git.kernel.org/linus/08389d888287c3823f80b0216766b71e17f0aba5

Add a kconfig knob which allows for unprivileged bpf to be disabled by default.
If set, the knob sets /proc/sys/kernel/unprivileged_bpf_disabled to value of 2.

This still allows a transition of 2 -> {0,1} through an admin. Similarly,
this also still keeps 1 -> {1} behavior intact, so that once set to permanently
disabled, it cannot be undone aside from a reboot.

We've also added extra2 with max of 2 for the procfs handler, so that an admin
still has a chance to toggle between 0 <-> 2.

Either way, as an additional alternative, applications can make use of CAP_BPF
that we added a while ago.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/74ec548079189e4e4dffaeb42b8987bb3c852eee.1620765074.git.daniel@iogearbox.net
[Salvatore Bonaccorso: Backport to 5.10.y: Filename change from
kernel/bpf/Kconfig back to init/Kconfig]

Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name bpf-Add-kconfig-knob-for-disabling-unpriv-bpf-by-def.patch
Documentation/admin-guide/sysctl/kernel.rst
init/Kconfig
kernel/bpf/syscall.c
kernel/sysctl.c